#include "include/io.h"
void bitSet(volatile BYTE *pSource, const BYTE bit)
{
  if (!(bit < 0 || bit > 7))
    (*pSource) = (*pSource) | (1 << bit);
  else
    xthrow(GENERAL_IO_EXCEPTION);
}

void bitReset(volatile BYTE *pSource, BYTE bit)
{
  if (!(bit < 0 || bit > 7))
    (*pSource) = (*pSource) & (~(1 << bit));
  else
    xthrow(GENERAL_IO_EXCEPTION);
}

BOOL bitState(const BYTE *pSource, BYTE bit)
{
  if (!pSource)
    xthrow(INVALID_IO_POINTER_OPERATION);
  return (*pSource) & (1 << bit);
}

void writeByte(volatile BYTE *pSource, BYTE value)
{
  if (!pSource)
    xthrow(INVALID_IO_POINTER_OPERATION);
  *pSource = value;
}

void moveByte(const BYTE *pSource, volatile BYTE *pDest)
{
  if ((!pSource) || (!pDest))
    xthrow(INVALID_IO_POINTER_OPERATION);
  *pDest = *pSource;
}

void pointTo(const BYTE *pFrom, volatile BYTE *pTo)
{
  if ((!pFrom) || (!pTo))
    xthrow(INVALID_IO_POINTER_OPERATION);
  pTo = pFrom;
}
